<?php
	$seitcm_class_id = isset($seitcm_class_id) ? $seitcm_class_id : 0;
	$seitcm_mark_list = seitcm_get_class_student_list($seitcm_class_id);
	$seitcm_student_id = isset($_GET['student']) ? $_GET['student'] : 0;
	$seitcm_student_data = seitcm_get_single_student($seitcm_student_id);
	if(!seitcm_check_exist_student_id($seitcm_student_id))
	{
		//404
	}
	else {
		$seitcm_score = isset($_POST['seitcm_score']) ? $_POST['seitcm_score'] : -1;
		$seitcm_skill = isset($_POST['seitcm_skill']) ? $_POST['seitcm_skill'] : 0;
		$seitcm_formvalidate = true;
		$seitcm_formvalidatemess = '';
		$seitcm_added = false;
		if($seitcm_score==-1)
		{
			$seitcm_formvalidate = false;
			$seitcm_formvalidatemess = $seitcm_formvalidatemess.__('"Score" is required','SEITCM').'<br />';
		}
		else if(!is_numeric($seitcm_score))
		{
			$seitcm_formvalidate = false;
			$seitcm_formvalidatemess = $seitcm_formvalidatemess.__('"Score" must be numberic','SEITCM').'<br />';
		}
		if($seitcm_skill==0)
		{
			$seitcm_formvalidate = false;
			$seitcm_formvalidatemess = $seitcm_formvalidatemess.__('"Skill" has not selected','SEITCM').'<br />';
		}
		if($seitcm_formvalidate && !empty($_POST)){
			if(seitcm_add_single_score($seitcm_student_id, $seitcm_class_id, $seitcm_score, $seitcm_skill, 0))
			{
				$seitcm_added = true;
			}
		}
?>
								<div class="modal_dialog"
									title="Add periodic peviews score for <?php echo get_user_meta($seitcm_student_id, 'first_name', true)?>"
									id="periodicpreviews_input_<?php echo $seitcm_student_id?>">
									<?php 
										if($seitcm_added == false)
										{
											if(!empty($_POST) && !$seitcm_formvalidate)
											{
												?>
												<div class="ui-widget seitcm_messbox">
													<div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
														<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
														<strong><?php _e('Error!','SEITCM')?><br /></strong><?php echo $seitcm_formvalidatemess?></p>
													</div>
												</div>
												<?php 
											}
												?>
									<form method="post" class="seitcm_form" action="admin.php?page=seitcm_class_option_menu&module=score&class=<?php echo $seitcm_class_id?>&action=periodicpreviews&student=<?php echo $seitcm_student_id?>"><fieldset>
										<label><?php _e('Skill','SEITCM')?></label>
		    							<select class="seitcm_skill" name="seitcm_skill">
		    								<option value="" <?php echo $seitcm_skill == 0 ? 'selected="selected"' : ''?>><?php _e('Chose skill','SEITCM')?></option>
		    								<?php 
		    								global $seitcm_score_skill;
		    								foreach ($seitcm_score_skill as $skill)
		    								{
		    								?>
		    									<option value="<?php echo $skill['key']?>" <?php echo $seitcm_skill == $skill['key'] ? 'selected="selected"' : ''?>><?php echo $skill['Value']?></option>
		    								<?php
		    								}
		    								?>
		    							</select>
		    							<label><?php _e('Score','SEITCM')?></label>
		    							<input type="text" name="seitcm_score" value="<?php echo $seitcm_score ==-1 ? '' : $seitcm_score?>">
		    							<label></label>
		    							<span class="seitcm_button_wrapper">
		    								<input type="submit" value="<?php _e('Save','SEITCM')?>">
		    								<a style="margin-top: 5px; padding: 0px 5px 6px 5px; height: 17px;" href="admin.php?page=seitcm_class_option_menu&module=score&class=<?php echo $seitcm_class_id?>"><?php _e('Cancel','SEITCM')?></a>
		    							</span>
		    						</fieldset></form>	
		    						<?php 
										}
										else if($seitcm_added)
										{
											?>
											<div class="ui-widget seitcm_messbox">
								                <div class="ui-state-highlight ui-corner-all" style="padding: 0 .7em;">
								                    <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
								                    <strong><?php _e('Success! ','SEITCM')?></strong><?php _e('Added new score','SEITCM')?>
								                    </p>
								                </div>
								            </div>
								            <span class="seitcm_button_wrapper" style="margin: 10px auto; display: block; text-align: center">
								            	<a href="admin.php?page=seitcm_class_option_menu&module=studentlist&class=<?php echo $seitcm_class_id?>" style="float: none;"><?php _e('Student list','SEITCM')?></a>
								            	<a href="admin.php?page=seitcm_class_option_menu&module=score&class=<?php echo $seitcm_class_id?>&action=list" style="float: none;"><?php _e('Score list','SEITCM')?></a>
								            </span>
											<?php 
										}
		    						?>    						
		    						</div>
		    						
		    						<script type="text/javascript">
			    						$(document).ready(function() {
			    							$( "#periodicpreviews_input_<?php echo $seitcm_student_id?>" ).dialog({
			    							      autoOpen: true,
			    							      modal: true,
			    							      width: 400,
			    							      close: function() {
			    							    	  $( "#periodicpreviews_input_<?php echo $seitcm_student_id?>" ).dialog('open');
			    							      },
			    							      
			    							    });
			    							$('.seitcm_skill').mouseover(function()
		    								    {
		    								       $('select.seitcm_skill option').css("font-family","Trebuchet MS").css("font-size","9px");        
		    								    });
		    							});
		    						</script>
		    						<?php
	}
		    						?>
